﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace ExpressionSerialization
{
    public interface IClient<TChannel> where TChannel : IQueryService
    {
        TResult SynchronousCall<TResult>(Expression<Func<TChannel, object>> methodcall);
        IEnumerable<Type> KnownTypes { get; }

        /// <summary>
        /// Specifying the returnType is necessary because sometimes DataContractSerializer cannot deserialize the response
        /// without knowing the exact Type of the response.
        /// Sometimes DCS fails to deserialize, sometimes it doesn't, but the best practice is to always specify the expected return Type.
        /// 
        /// If calling from SL, this call must be made from a thread separate from the main UI thread. For example,
        /// enclose this call within a call to ThreadPool.QueueUserWorkItem.
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="methodcall">Lambda Expression that is the call to a method on the WebHttp service.</param>
        /// <param name="returnType">expected Type returned in the response</param>
        /// <returns></returns>
        //public object SynchronousCall<TResult>(Expression<Func<TChannel, TResult>> methodcall, Type returnType = null)
        object SynchronousCall(Expression<Func<TChannel, object>> methodcall, Type returnType);
    }
}